<%@ page import="java.util.Iterator" %>
<%@ page import="fr.mywiki.view.web.struts.form.entry.EditEntryForm" %>
<%@ page import="fr.mywiki.business.entry.meta.EntryModel" %>

<%
	EditEntryForm editEntryForm = (EditEntryForm) session.getAttribute("editEntryForm");
%>

<html:hidden property="selectedModelId" value=""/>

<script>
<!--
function selectModel(id) {
	document.forms["editEntryForm"].method.value='modelSelected';
	document.forms["editEntryForm"].selectedModelId.value=id;
	document.forms["editEntryForm"].submit();
}
-->
</script>

<div dojoType="dijit.Dialog" id="dialogSelectModel" closeScript="dijit.byId('dialogSelectModel').hide()"
		title="Model selection"
		closeTitle="<bean:message key="action.close"/>">
	<p>Please choose a model:</p>

<%
	Iterator itModels = editEntryForm.getSelectableModels().iterator();
	while(itModels.hasNext()) {
		EntryModel model = (EntryModel) itModels.next();
%>
		<p>
			<a href="#"	onclick="javascript:selectModel('<%=model.getId()%>');" >
				<%=model.getName()%>
			</a>
		</p>
<%
	}
%>

	<div class="buttonPosition">
		<html:button property="actionSubmit" onclick="dijit.byId('dialogSelectModel').hide();">
			<bean:message key="action.cancel"/>
		</html:button>
	</div>
</div>